package com.qfedu.buy.common.util;

import com.qfedu.buy.common.config.SystemConfig;

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

/**
 * @program: NeighborBuy
 * @description:
 * @author: Feri(邢朋辉)
 * @create: 2021-01-26 15:49
 */
public class DateUtil {
    /**
     * 比较日期是否为今天*/
    public static boolean eqdate(Date date){
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
        return (sdf.format(date)).equals(sdf.format(new Date()));
    }
    /**
     * 比较日期是否为昨天*/
    public static boolean eqyesterday(Date date){
        Calendar calendar=Calendar.getInstance();
        //日期改为昨天
        calendar.add(Calendar.DAY_OF_MONTH,-1);
        SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd");
        return (sdf.format(date)).equals(sdf.format(calendar.getTime()));
    }
    //比较日期
    /**
     * 比较指定时间和当前时间的关系
     * >0
     * =0 一样
     * <0 */
    public static long eqtime(Date time){
        return time.getTime()- System.currentTimeMillis();
    }
}
